<template>
	<view class="all_lotteries">
		<uni-nav-bar fixed status-bar :border="false" left-icon="left" title="全部抽奖" @clickLeft="back" />
		<view class="tabs">
			<view :class="{ active: type == '1' }" @click="selectEvt('1')">满人开奖</view>
			<view :class="{ active: type == '2' }" @click="selectEvt('2')">定时开奖</view>
			<view :class="{ active: type == '3' }" @click="selectEvt('3')">即开即抽</view>
		</view>
		<view class="content" v-if="taskList.length">
			<view class="row clearfix mt20" v-for="(item, index) in taskList" :key="index">
				<image :src="`${domain}${item.template.url}`" alt=""></image>
				<p v-for="(i, idx) in item.task_draw" :key="index+'_'+idx">
					{{ `${i.level_name}: ${i.draw_name}*${i.draw_num}` }}
				</p>
				<p v-if="item.task_comfort">
					{{ `${item.task_comfort.level_name}: ${item.task_comfort.draw_name}*${item.task_comfort.draw_num}` }}
				</p>
				<p class="line"></p>
				<p class="fl">{{ type2[item.type] }}</p>
				<p class="fr c_C30000 fwb">{{ type1[item.status] }}</p>
			</view>
			<p v-if="showMore" class="tac mt20 mb50" @click="loadMore">点击加载更多</p>
			<p v-else class="tac mt20 mb50">没有更多了</p>
		</view>
		<view v-else class="tac empty">
			暂无数据
		</view>
	</view>
</template>
<script>
	// status 已发布 4 已借su 0 daifabu
	// type 1 jichoujikai  2 dingshikaijiang 3满人开奖
	const type1 = {
		1: '已发布',
		0: '待发布',
		4: '已结束'
	}
	const type2 = {
		1: '即抽即开',
		2: '定时开奖',
		3: '满人开奖'
	}
	export default {
		data() {
			return {
				domain: uni.$http.baseUrl + "/",
				type1,
				type2,
				taskList: [],
				type: '1',
				page: 1,
				num: 10,
				showMore: true
			}
		},
		methods: {
			back() {
				uni.navigateBack();
			},
			getTaskList() {
				const {
					page,
					num,
					type
				} = this;
				uni.$http.get('/user/public/allTaskIndex', {
					page,
					num,
					type
				}).then(res => {
					if (res.data.data.list.length) {
						this.taskList.push(...res.data.data.list);
					} else {
						this.showMore = false;
					}
				})
			},
			selectEvt(value) {
				this.type = value;
				this.page = 1;
				this.taskList = [];
				this.showMore = true;
				this.getTaskList();
			},
			loadMore() {
				this.page++;
				this.getTaskList();
			},
			jumpPage(value) {
				uni.setStorageSync('task_info', value);
				uni.navigateTo({
					url: '/pagesMy/myPrize/index'
				})
			}
		},
		onLoad() {
			this.getTaskList();
		}
	}
</script>
<style lang="scss" scoped>
	.all_lotteries {
		.tabs {
			display: flex;
			flex-wrap: nowrap;
			justify-content: space-between;
			background-color: #fff;
			padding: 10rpx 20rpx 0;

			.active {
				font-weight: bold;

				&::after {
					content: '';
					display: block;
					width: 50rpx;
					height: 6rpx;
					background-color: #000;
					margin-left: 50%;
					margin-top: 10rpx;
					transform: translateX(-50%);

				}
			}

		}

		.content {
			padding: 20rpx;

			.row {
				background-color: #fff;
				padding: 20rpx;
				border-radius: 20rpx;

				image {
					width: 100%;
					border-radius: 20rpx;
				}

				p {
					line-height: 50rpx;
				}

				.line {
					margin: 10rpx 0;
					border-top: 1px dashed #707070;
				}

				.c_C30000 {
					color: #C30000;
				}
			}
		}

		.empty {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translateX(-50%);
		}
	}
</style>